home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / breakRigidBodyConnections.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.0 KB  |  96 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Alias|Wavefront Script File
  19. // MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //
  22.  
  23. global proc breakRigidBodyConnections()
  24. //
  25. // This proc deletes all the connections to a rigid body that are not connections
  26. // from the solver.
  27. //
  28. {
  29.     int    $i, $j, $k;
  30.     string $selObj[] = `ls -sl`;
  31.  
  32.     // For each object in the selection list, check to see if
  33.     // and rigid bodies are present.
  34.     //
  35.     for ($i = 0; $i < size( $selObj ); $i++)
  36.     {
  37.         // Get a list of selected items and thier children.
  38.         //
  39.         string $kids[] = `ls -dag -leaf -showType $selObj[$i]`;
  40.  
  41.         // Check to see if we have any rigid bodies.
  42.         //
  43.         for ($j = 0; $j < size( $kids ); $j += 2)
  44.         {
  45.             // If a rigid body is found process it.
  46.             //
  47.             if ($kids[$j+1] == "rigidBody")
  48.             {
  49.                 string $rigidName    = $kids[$j] + ".choice";
  50.                 string $bakeSimIndex = $kids[$j] + ".bakeSimulationIndex";
  51.  
  52.                 string $choiceList[] = `connectionInfo -dfs $rigidName`;
  53.  
  54.                 // Get the choice node.
  55.                 //
  56.                 for ( $k = 0; $k < size( $choiceList ); $k++ )
  57.                 {
  58.                     string $choiceNode[] = `ls -o $choiceList[$k]`;
  59.                     string $destination  = $choiceNode[0] + ".input[1]";
  60.                     string $source       = `connectionInfo -sfd $destination`;
  61.  
  62.                     if ( ( size( $source ) > 0 ) && ( size( $destination ) > 0 ) )
  63.                     {
  64.                         disconnectAttr $source $destination;
  65.                     }
  66.  
  67.                     $destination  = $choiceNode[0] + ".input[2]";
  68.                     $source       = `connectionInfo -sfd $destination`;
  69.  
  70.                     if ( ( size( $source ) > 0 ) && ( size( $destination ) > 0 ) )
  71.                     {
  72.                         disconnectAttr $source $destination;
  73.                     }
  74.                 }
  75.  
  76.                 // If there is a connection to the bake sim attribute then we have
  77.                 // been baked.  Disconnect the connection to this attribute.
  78.                 //
  79.                 if ( $bakeSimIndex != -1 )
  80.                 {
  81.                     string $source = `connectionInfo -sfd $bakeSimIndex`;
  82.  
  83.                     if ( ( size( $source ) > 0 ) && ( size( $bakeSimIndex ) > 0 ) )
  84.                     {
  85.                         disconnectAttr $source $bakeSimIndex;
  86.                     }
  87.  
  88.                     // Reset the bake sim index.
  89.                     //
  90.                     setAttr $bakeSimIndex -1;
  91.                 }
  92.             }
  93.          }
  94.     }
  95. }
  96.